<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />

<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>添加规格</title>
</head>
<body>
<div class="pd-20">
	<form action="" method="post" class="form form-horizontal" id="form1">
		<input type="hidden" name="goods_id" id="goods_id">
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>秒杀价格：</label>
			<div class="formControls col-4">
				<input type="number" class="input-text" value="" placeholder="" id="seckill_cost" name="seckill_cost" datatype="n1-16" nullmsg="秒杀价格不能为空">
			</div>
			<div class="col-3"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>开始时间：</label>
			<div class="formControls col-4">
				<input class="input-text" id="add_time" type="text" name="add_time" value="" datatype="*" nullmsg="开始时间不能为空">
			</div>
			<div class="col-3"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>结束时间：</label>
			<div class="formControls col-4">
				<input class="input-text" id="end_time" type="text" name="end_time" value="" datatype="*" nullmsg="结束时间不能为空">
			</div>
			<div class="col-3"> </div>
		</div>
		<div class="row cl">
			<div class="col-9 col-offset-3">
				<input class="btn btn-primary radius" type="button" id="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</div>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/Validform/5.3.2/Validform.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.1/layer.js"></script> 
<script type="text/javascript" src="js/H-ui.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script> 
<script type="text/javascript" src="js/s.js"></script>
<script type="text/javascript" src="lib/daterangepicker/moment.min.js"></script> 
<script type="text/javascript" src="lib/daterangepicker/jquery.daterangepicker.js"></script>
<link rel="stylesheet" href="lib/daterangepicker/daterangepicker.css" />
<script type="text/javascript">
$("#form1").attr("action", API_SECKILL_EDIT);
var editid=getUrlParam('editid');
if(editid!==null){
	var eidturl=API_SECKILL_EDIT+'?id='+editid;
	$("#form1").attr("action", eidturl);
	$.getJSON(eidturl,function(data){
    	if(!checkStatus(data)) return;
    	
    		
    		$("input[name='sku_info']").val(data.datas.sku_info);
    		$("input[name='sku_info']").attr("readOnly","true");
    		$("input[name='sku_num']").val(data.datas.sku_num);
    		$("input[name='sku_cost']").val(data.datas.sku_cost);
    		// $("input[name='sku_group_cost']").val(data.datas.sku_group_cost);


    		$("input[name='sku_weight']").val(data.datas.sku_weight);
    		// $("input[name='sku_max_quan']").val(data.datas.sku_max_quan);
    		// $("input[name='sku_bespeak_num']").val(data.datas.sku_bespeak_num);


    		$("input[name='sku_state'][value="+data.datas.sku_state+"]").attr("checked",true);

    		if(data.datas.sku_image!==""){
            	$("#imgslt").html('<img src="'+data.datas.sku_image+'"><i class="icon Hui-iconfont fun-img-del" data-id="#imgslt" data-inputname="sku_image"></i><input type="hidden" name="sku_image" value="'+data.datas.sku_image+'">');
            }

            
        
    })
}
$('#add_time').dateRangePicker({
	autoClose: true,
	singleDate : true,
	singleMonth: true,
	showShortcuts: false,
	startOfWeek: 'monday',
	format: 'YYYY-MM-DD HH:mm:ss',
	time: {
		enabled: true
	},
	defaultTime: moment().startOf('day').toDate(),
	defaultEndTime: moment().endOf('day').toDate(),
});
$('#end_time').dateRangePicker({
	autoClose: true,
	singleDate : true,
	singleMonth: true,
	showShortcuts: false,
	startOfWeek: 'monday',
	format: 'YYYY-MM-DD HH:mm:ss',
	time: {
		enabled: true
	},
	defaultTime: moment().startOf('day').toDate(),
	defaultEndTime: moment().endOf('day').toDate(),
});
$(function(){
	$(document).on('click','input#submit',function(){
		$("#form1").Validform({
	        tiptype:2,
	        ajaxPost:true,
	        callback:function(data){
	            if( data.status == 1 ){
	                var index = parent.layer.getFrameIndex(window.name);
	                parent.parent.layer.msg(data.info, {icon:1,time:1000});
                	// 修改商品时添加规格
                	if( editid==null ){
	                	parent.$("#seckill-list").append(
	                		'<tr id="seckill466">'+
			                	'<td class="text">新增</td>'+
			                	'<td class="text">'+$('#seckill_cost').val()+'</td>'+
			                	'<td class="text">'+$('#add_time').val()+'</td>'+
			                	'<td class="text">'+$('#end_time').val()+'</td>'+
			                	'<td><a style="text-decoration:none" class="ml-5 edit" href="javascript:;" title="编辑"><i class="Hui-iconfont"></i></a></td>'+
		                	'</tr>'
	                	);
	                }else{
	                	// 修改商品时修改规格
	                	var idname="#sku"+editid;
	                	parent.$(idname).html();
	                }
	                parent.layer.close(index); 
	            }
	        }
	    });
	    $("#form1").submit();
	})
});
</script>
</body>
</html>